package demo;

public class test2 {
    public static void main(String[] args) {
        int[] arr = {10, 20, 30, 40, 50};
        int j = arr.length - 1;

        for (int i = 0 ; i < j; i++, j--) {

            int temp = arr[j];

            arr[j] = arr[i];

            arr[i] = temp;

        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i] + " ");
        }
        //这种方法也行
        /*int[] arr = {10, 20, 30, 40, 50};

        for (int i = 0, j = arr.length - 1; i < j; i++, j--) {

            int temp = arr[j];

            arr[j] = arr[i];

            arr[i] = temp;
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i] + " ");
        }*/
    }
}
